# -*- coding: utf-8 -*-
import scrapy
from scrapy.loader import ItemLoader

from biquyun.items import BiquyunItem


class HotcontentSpider(scrapy.Spider):
    name = 'hotcontent'
    allowed_domains = ['www.biquyun.com']
    start_urls = ['http://www.biquyun.com/']

    def parse(self, response):
        self.log("热门排行===================")
        items = response.css('#hotcontent .item dl dt')
        for item in items:
            self.log(item)
            loader = ItemLoader(item=BiquyunItem(), selector=item)
            loader.add_css('author', 'span ::text')
            loader.add_css('title', 'a ::text')
            loader.add_css('url', 'a ::attr(href)')
            yield loader.load_item()
